package org.jfbmonitor.view.transaction;

import java.awt.Color;
import java.awt.Component;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

public class TransactionCellRenderer extends DefaultTableCellRenderer {	
	private static final long serialVersionUID = 1L;
	
	public TransactionCellRenderer() {
		super();
	}
	
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		JLabel label = (JLabel) super.getTableCellRendererComponent(table,
				value, isSelected, hasFocus, row, column);
		
		if (column == 0) {
			label.setHorizontalAlignment(JLabel.CENTER);
		} else {
			label.setHorizontalAlignment(JLabel.LEFT);
		}
		if (isSelected) {
			label.setForeground(Color.WHITE);
			Color color = new Color(10, 36, 100);
			label.setBackground(color);
		} else {
			label.setForeground(Color.BLACK);

			if (row % 2 != 0) {
				Color yellow = new Color(255, 255, 223);
				label.setBackground(yellow);
			} else {
				label.setBackground(Color.WHITE);
			}
		}
		return label;
	}
}
